/* 调用实例
		//程序中关闭弹出框
		function close(){
			$.hsAlert.close();
		}
		//confirm的回调方法
		function alertCall(result){
			if(result=="yes")
			{
				alert("已点击确认");
			}else{
				alert("已点击取消");
				}
			}
		//跳转的回调方法
		function jumpCall(){
				alert("开始跳转");//自行设置跳转页面
		}
		//三个不同的实例
		function opens(){
			//$.hsAlert.open({title:"删除",content:"确认删除吗？",dtype:"confirm",details:"删除后将无法恢复",callback:alertCall});
			//$.hsAlert.open({title:"删除",content:"已成功删除",dtype:"alert",time:15,showtime:true,details:"马上自动返回哦"});
			$.hsAlert.open({title:"超时提示",content:"登录已超时",dtype:"alert",time:5,details:"马上自动跳转到登录页哦",callback:jumpCall});
		}
		$(function() {
		 	opens();
		 })
**/

;
!function($) {
	$.hsAlert = {
		dia : null,
		data : null,
		open : function(data) {
			this.data = data;
			if (this.dia && this.dia != null) {
				this.dia.remove();
				this.dia = null;
			}
			if (data.dtype == "alert") {
				var str = "<div id=\"dialog-" + data.dtype + "\" title=\""
						+ data.title + "\">";
				str += "<p><span class=\"icon32 icon-orange icon-info\" style=\"float:left; margin:0 7px 50px 0;\"></span><b><span id=\"contentTitle-"
						+ data.dtype + "\">" + data.content + "</span></b>";
				str += "</p><p><span id=\"timecount-" + data.dtype
						+ "\"></span> <span id=\"content-" + data.dtype + "\">"
						+ data.details + "</span></p></div>";
				$("body").append(str);

				this.dia = $("#dialog-" + data.dtype).dialog({
					modal : true,
					autoOpen : true,
					buttons : {
						确定 : function() {
							if (inter) {
								clearInterval(inter);
							}
							$(this).dialog("close");
							if(data.callback &&data.callback!=null){
							data.callback();}
						}
					}
				});
				if(data.time){
					var i;
					var inter;
					function closetime() {
						i = data.time;
						if(data.showtime){
						$("#timecount-" + data.dtype).html(data.time);}
						inter = window.setInterval(function() {
							--i;
							if(data.showtime){
							$("#timecount-" + data.dtype).html(i);}
							if (i <= 0) {
								clearInterval(inter);
								$("#dialog-" + data.dtype).dialog("close");
								if(data.callback &&data.callback!=null){
								data.callback();
								}
							}
						}, 1000);
					}
					closetime();
				}
			} else if (data.dtype == "confirm") {
				var str = "<div id=\"dialog-" + data.dtype + "\" title=\"" + data.title + "\">";
				str += "<p><span class=\"icon32 icon-red icon-alert\" style=\"float:left; margin:0 7px 50px 0;\"></span><b><span id=\"contentTitle-"
						+ data.dtype + "\">" + data.content + "</span></b>";
				str += "</p><p><span id=\"content-" + data.dtype + "\">"
						+ data.details + "</span></p></div>";
				$("body").append(str);

				this.dia = $("#dialog-" + data.dtype).dialog({
					modal : true,
					autoOpen : true,
					buttons : {
						确定 : function() {
							$(this).dialog("close");
							data.callback("yes");
						},
						取消 : function() {
							$(this).dialog("close");
							data.callback("no");
						}
					}
				});

			}
		},
		close : function() {
			$("#dialog-" + dtype).dialog("close");
		}
	};
}(jQuery);